
var path = require('path');
var simpleGit = require('simple-git');

var workspacesPath = "/paasdb/workspaces";

var repoPath = path.join(workspacesPath, 'workspacenamespaceold01', 'source', 'namespaceold');
var newRemotePath = "git@123.56.190.188:namespace_new.git";


modifyRemoteRepo(repoPath, newRemotePath, 'develop', 'namespaceold01');


function modifyRemoteRepo(repoPath, newRemotePath, branchName, workspaceName){
    var git = simpleGit(repoPath);

    git.removeRemote('origin')
        .addRemote('origin', newRemotePath)
        .push(['-u', 'origin', branchName], function (err) {
            if(!err){
                console.log('modify workspace '+ workspaceName + ' remote repo success!');
            }else{
                console.log('modify workspace '+ workspaceName + ' remote repo failed!');
            }
        });
}